#pragma once
#include <vector>
#include <Eigen/Core>

class  BSpline
{
public:
	BSpline();
	virtual ~BSpline();
	static BSpline CubicApproximate(const std::vector<Eigen::Vector3d>& vecFitPoints, double alpha, double beta);
	static BSpline Interpolate3Degree(const std::vector<Eigen::Vector3d> pPoints);
	Eigen::Vector3d Evaluate(double u);
	std::vector<Eigen::Vector3d> m_vecCVs;
	std::vector<double> m_vecKnots;

protected:
	static void SecondDerivativeCoefficient(int i, const std::vector<double>& u, std::vector<std::pair<double, double>>& a_b_array);
	static void WMatrix(Eigen::MatrixXd& W, int n, int p, const std::vector<double>& u);
	static double PolynomialIntegral(double quad, double linear, double con, double start, double end);
	void BasisFunc(double u, int k, std::vector<double>& basis_func);
	void KnotNormailize();
protected:
	int m_nDegree;

};

